<template>
	<view class="input-mobile-main-box">
		<view class="input-box-bg">
			<image class="bg" mode="widthFix"
				src="https://h5.sx2b2c.com/images/tequan/ximalaya/0.01/input-mobile-bg.png"></image>
			<view class="input-box">
				<!-- @input="inputPhone" -->
				<input focus="true" class="input" type="text" maxlength="11"  v-model="mobile"
					placeholder="输入领取手机号">
				<view @click="submit" class="btn">立即领取</view>
			</view>
		</view>
		<image mode="widthFix" class="close" @click="closeHandler"
			src="https://h5.sx2b2c.com/images/tequan/ximalaya/0.01/close-icon.png">
		</image>
	</view>
</template>

<script>
	import messageUtil from '../../utils/messageUtil';
	import validParamsUtil from '../../utils/validParamsUtil';
	export default {
		name: "xmly-input-mobile",
		data() {
			return {
				mobile: '',
			};
		},
		methods: {
			submit() {
				if (!validParamsUtil.validPhone(this.mobile)) {
					messageUtil.showFail('手机号不正确');
					return;
				}
				this.$emit('success', this.mobile)
			},
			inputPhone(e){
				this.mobile = e.detail.value
			},
			closeHandler() {
				this.$emit('close')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.input-mobile-main-box {
		position: fixed;
		width: 100%;
		height: 100vh;
		left: 0;
		top: 0;
		background: url('https://h5.sx2b2c.com/images/tequan/ximalaya/0.01/shadown.png');
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;

		.input-box-bg {
			width: 90%;
			position: relative;

			.bg {
				display: block;
				width: 100%;
				height: auto;
			}

			.input-box {
				position: absolute;
				width: 90%;
				left: 5%;
				bottom: 40rpx;

				.input {

					height: 90rpx;
					background: #FFFFFF;
					border: 1px solid #5CBE72;
					border-radius: 45rpx;
					font-size: 32rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #666666;
					box-sizing: border-box;
					padding-left: 30rpx;
				}

				.btn {
					margin-top: 32rpx;
					height: 90rpx;
					line-height: 90rpx;
					background: #2DA145;
					border-radius: 45rpx;
					font-size: 32rpx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					color: #FFFFFF;
					text-align: center;
				}
			}
		}

		.close {
			width: 50rpx;
			height: auto;
			margin-top: 30rpx;
		}
	}
</style>